<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="ArticulosListForm">

        <p:panel header="#{myBundle.ListArticulosTitle}">

            <p:dataTable id="datalist" value="#{articulosController.items}" var="item"
                         selectionMode="single" selection="#{articulosController.selected}"
                         rowKey="#{item.codArticulo}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.codArticulo}" filterBy="#{item.codArticulo}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_codArticulo}"/>
                    </f:facet>
                    <h:outputText value="#{item.codArticulo}"/>
                </p:column>
                <p:column sortBy="#{item.descripcion}" filterBy="#{item.descripcion}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_descripcion}"/>
                    </f:facet>
                    <h:outputText value="#{item.descripcion}"/>
                </p:column>
                <p:column sortBy="#{item.nroParte}" filterBy="#{item.nroParte}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_nroParte}"/>
                    </f:facet>
                    <h:outputText value="#{item.nroParte}"/>
                </p:column>
                <p:column sortBy="#{item.precio}" filterBy="#{item.precio}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_precio}"/>
                    </f:facet>
                    <h:outputText value="#{item.precio}"/>
                </p:column>
                <p:column sortBy="#{item.codOrigen}" filterBy="#{item.codOrigen}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_codOrigen}"/>
                    </f:facet>
                    <h:outputText value="#{item.codOrigen}"/>
                </p:column>
                <p:column sortBy="#{item.costoCalculado}" filterBy="#{item.costoCalculado}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_costoCalculado}"/>
                    </f:facet>
                    <h:outputText value="#{item.costoCalculado}"/>
                </p:column>
                <p:column sortBy="#{item.saldoActual}" filterBy="#{item.saldoActual}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_saldoActual}"/>
                    </f:facet>
                    <h:outputText value="#{item.saldoActual}"/>
                </p:column>
                <p:column sortBy="#{item.porcentajeIva}" filterBy="#{item.porcentajeIva}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_porcentajeIva}"/>
                    </f:facet>
                    <h:outputText value="#{item.porcentajeIva}"/>
                </p:column>
                <p:column sortBy="#{item.costo1}" filterBy="#{item.costo1}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_costo1}"/>
                    </f:facet>
                    <h:outputText value="#{item.costo1}"/>
                </p:column>
                <p:column sortBy="#{item.costo2}" filterBy="#{item.costo2}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_costo2}"/>
                    </f:facet>
                    <h:outputText value="#{item.costo2}"/>
                </p:column>
                <p:column sortBy="#{item.codMarca.descripcion}" filterBy="#{item.codMarca.descripcion}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_codMarca}"/>
                    </f:facet>
                    <h:outputText value="#{item.codMarca.descripcion}"/>
                </p:column>
                <p:column sortBy="#{item.codFamilia.descripcion}" filterBy="#{item.codFamilia.descripcion}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListArticulosTitle_codFamilia}"/>
                    </f:facet>
                    <h:outputText value="#{item.codFamilia.descripcion}"/>
                </p:column>
                <f:facet name="footer">
                    <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{myBundle.Create}" actionListener="#{articulosController.prepareCreate}" update=":ArticulosCreateForm" oncomplete="ArticulosCreateDialog.show()"/>
                    <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{myBundle.View}" update=":ArticulosViewForm" oncomplete="ArticulosViewDialog.show()" disabled="#{empty articulosController.selected}"/>
                    <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{myBundle.Edit}" update=":ArticulosEditForm" oncomplete="ArticulosEditDialog.show()" disabled="#{empty articulosController.selected}"/>
                    <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{myBundle.Delete}" actionListener="#{articulosController.delete}" update=":growl,datalist" disabled="#{empty articulosController.selected}"/>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>